<template>
<div>
    <van-nav-bar
  title="网上选课"

  right-text="返回系统主页"


  @click-right="onClickRight"
/>
</div>

<van-grid :gutter="10" >
  <van-grid-item  v-for="value in courselist" :key="value"  style="--van-grid-item-icon-size:150px"  @click="choseCourse(value.course_id)">
     <van-icon name="label-o"/>
     <div><span >{{value.course_name}}</span></div>
    
 
</van-grid-item>
</van-grid>
<!-- <span>{{courselist.course_name}}</span> -->

<div>
 
</div>
</template>

<script>



export default {
   data(){
    return{
        courselist:[],
        queryInfo:{
            query: '',
          // 当前的页数
          pagenum: 1,
          // 当前每页显示多少条数据
          pagesize: 10000000,
          //选择是课程的类型
          capacity:''
        },
        
        
    }
   },
   created(){
    this.getCourseList()
   },
   methods:{
    onClickRight(){
      this.$router.push('/welcome')
    },
    async getCourseList() {
        const { data: res } = await this.$http.post('courseList',this.queryInfo
        )
        console.log(res)
        if (res === null) {
          return this.$message.error('获取课程数据失败！')
        }
        
        // res.filter(x=>x.course_put_status && ).forEach(x=>{
        //   this.courselist.push(x)
        // })
        for (let index = 0; index < res.length; index++) {
          if(res[index].course_status ===1 && res[index].course_put_status === 1)
          this.courselist.push(res[index])
        }
        // this.total = res.data.total
        console.log(this.courselist)
      },
      choseCourse(course_id){
       
        this.$router.push({
          name:'CourseDetailname',
          query:{
            id:course_id
          }
        })
     
     },

  
   },
  
}
 
  

</script>
<style lang="less">

</style>